@extends('backend::layout')

@section('title', '教师列表')

@section('content')
    <div class="card border-no">
        <div class="card-body">
            @if($currentAdmin->allow('teacher/add'))
                <div class="row">
                    <div class="clearfix"></div>
                    <div class="col-md-12 col-sm-12 col-xs-12 pull-right">
                        <p>
                            <a href="{{ $logistics?route('admin.logistics.add'):route('admin.teacher.add') }}" class="btn btn-primary btn-sm">
                                @if($logistics == 1)
                                    添加后勤教师
                                @else
                                    添加任课教师
                                @endif
                            </a>
                        </p>
                    </div>
                </div>
            @endif
                <form method="get">
                    <div class="row">
                        <div class="clearfix"></div>
                        <div class="col-md-12 col-sm-12 col-xs-12">
                            <label class="col-md-2 col-sm-12">
                                <input class="form-control" type="text" placeholder="教师编码" name="tc_code" value="{{ old("tc_code") ?: (isset($query['tc_code']) ? $query['tc_code'] : '') }}" />
                            </label>
                            <label class="col-md-2 col-sm-12">
                                <input class="form-control" type="text" placeholder="教师姓名" name="name" value="{{ old("name") ?: (isset($query['name']) ? $query['name'] : '') }}" />
                            </label>

                            <label class="col-md-2 col-sm-12">
                                <select class="form-control" id="agency" name="tl_code">
                                    <option  value="">--教师头衔--</option>
                                    @foreach($level as $val)
                                        <option value="{{ $val->tl_code }}" @if(old('tl_code') === $val->tl_code || (old('tl_code') === null && (isset($query['tl_code']) && $query['tl_code'] ==  $val->tl_code )) ) selected @endif >{{ $val->name }}</option>
                                    @endforeach
                                </select>
                            </label>

                            <label class="col-md-2 col-sm-12">
                                <button class="btn btn-primary btn-sm">搜索</button>
                            </label>
                        </div>
                    </div>
                </form>
{{--            <h4 class="text-black f-20">用户列表</h4>--}}
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                    <tr>
                        <th scope="col">#</th>
                        <th scope="col">{{ __('code') }}</th>
                        <th scope="col">{{ __('Username') }}</th>
                        <th scope="col">手机号码</th>
                        <th scope="col">头衔</th>
                        <th scope="col">{{ __('Create Time') }}</th>
                        <th scope="col">{{ __('Update Time') }}</th>
                        <th scope="col">{{ __('Options') }}</th>
                    </tr>
                    </thead>
                    <tbody>
                    @if(isset($list))
                        @foreach($list as $idx => $item)
                            <tr>
                                <th scope="row">{{ $idx + 1 }}</th>
                                <td>{{ $item->tc_code }}</td>
                                <td>{{ $item->name }}</td>
                                <td>{{ $item->phone }}</td>
                                <td>
                                    @foreach($item->levels as $level)
                                        <div>{{ $level->name }}</div>
                                    @endforeach
                                </td>
                                <td>{{ $item->created_at }}</td>
                                <td>{{ $item->updated_at }}</td>
                                <td>
{{--                                    @if(!empty($currentAdmin) && $currentAdmin->allow('user/view'))--}}
{{--                                        <a href="{{ route('admin.teacher.view', ['id' => $item->id]) }}" class="text-primary" title="{{ __('View') }}">&nbsp;&nbsp;<i class="fa fa-eye"></i></a>--}}
{{--                                    @endif--}}
                                    @if($logistics)
                                        @if($currentAdmin->allow('logistics/edit'))
                                            <a href="{{ route('admin.logistics.edit', ['id' => $item->id]) }}" class="text-info" title="{{ __('Edit') }}">&nbsp;&nbsp;<i class="fa fa-pencil"></i></a>
                                        @endif
                                        @if($currentAdmin->allow('logistics/delete'))
                                            <a href="{{ route('admin.logistics.delete', ['id' => $item->id]) }}" class="text-danger confirm-delete" title="{{ __('Delete') }}">&nbsp;&nbsp;<i class="fa fa-trash-o"></i></a>
                                        @endif
                                    @else
                                        @if($currentAdmin->allow('teacher/edit'))
                                            <a href="{{ route('admin.teacher.edit', ['id' => $item->id]) }}" class="text-info" title="{{ __('Edit') }}">&nbsp;&nbsp;<i class="fa fa-pencil"></i></a>
                                        @endif
                                        @if($currentAdmin->allow('teacher/delete'))
                                            <a href="{{ route('admin.teacher.delete', ['id' => $item->id]) }}" class="text-danger confirm-delete" title="{{ __('Delete') }}">&nbsp;&nbsp;<i class="fa fa-trash-o"></i></a>
                                        @endif
                                    @endif
                                </td>
                            </tr>
                        @endforeach
                    @endif
                    </tbody>
                </table>
            </div>
            <div class="row">
                <div class="clearfix"></div>
                <div class="col-md-12 col-sm-12 col-xs-12 pull-right">
                    @if(isset($list))
                        {{ $list->links() }}
                    @endif
                </div>
            </div>
        </div>
    </div>
@stop